package action;

import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

public class UserAction {

    public String showRegist(HttpServletRequest request, HttpServletResponse response){
        return "success";
    }
    public String showLogin(HttpServletRequest request, HttpServletResponse response){
        return "success";
    }
    public String showSuccess(HttpServletRequest request, HttpServletResponse response){
        return "success";
    }


    public String regist(HttpServletRequest request, HttpServletResponse response) {
        System.out.println("UserAction.regist()");

        String username = request.getParameter("username");
        String password = request.getParameter("password");
        String phone = request.getParameter("phone");

        if ("abc".equals(username)) {
            request.setAttribute("message", "用户名已存在");
            return "fail";
        }
        System.out.println("用户注册...");
        return "success";

    }

    public String login(HttpServletRequest request, HttpServletResponse response) {

        System.out.println("UserAction.login()");

        String username = request.getParameter("username");
        String password = request.getParameter("password");

        if("abc".equals(username)&&"123".equals(password)){
            System.out.println("用户登录...");
            return "success";
        }

        request.setAttribute("message","用户名或密码错误");
        return "fail";
    }





















}